<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<ul class="breadcrumb">
			<li>
				<i class="icon-home home-icon"></i>
				<a href="<?php echo PIUrl::createUrl('/admin');?>">Trang chủ</a>

				<span class="divider">
					<i class="icon-angle-right arrow-icon"></i>
				</span>
			</li>
			<li class="active"><?php echo translate('Cài đặt');?></li>
		</ul>
	</div>

	<div class="page-content">
		<div class="page-header position-relative">
			<h1>
				<?php echo translate('Cài đặt');?>
			</h1>
		</div><!--/.page-header-->
		<div class="row-fluid">
			<div class="span12">
				<!--PAGE CONTENT BEGINS-->
				<?php $form = $this->beginWidget('CActiveForm', array(
					'id'=>'system-form',
					//'enableAjaxValidation'=>true,
					'enableClientValidation'=>true,
					'focus'=>array($model,'title'),
					'htmlOptions'=>array('class'=>'form-horizontal', 'enctype'=>'multipart/form-data'),
				)); ?>
					<div class="control-group">
						<div class="controls">
							<img style="max-width: 500px; max-height:200px;" src="
								<?php
									echo file_exists(yii::app()->basePath."/../upload/images/".$model->logo) ?
									yii::app()->baseUrl."/upload/images/".$model->logo : yii::app()->baseUrl."/upload/images/noname.jpg";
								?>"/>
						</div>
					</div>
					<div class="control-group">
						<?php echo $form->labelEx($model,'logo',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->fileField($model,'logo',array('class'=>'id-input-file-1 span12')); ?>
							<?php echo $form->error($model,'logo'); ?>
						</div>
					</div>
					<div class="control-group">
						<div class="controls">
							<img style="max-width: 500px; max-height:200px;" src="
								<?php 
									echo file_exists(yii::app()->basePath."/../upload/images/".$model->banner) ?
									yii::app()->baseUrl."/upload/images/".$model->banner : yii::app()->baseUrl."/upload/images/noname.jpg";
								?>"/>
						</div>
					</div>
					<div class="control-group">
						<?php echo $form->labelEx($model,'banner',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->fileField($model,'banner',array('class'=>'id-input-file-1 span12')); ?>
							<?php echo $form->error($model,'banner'); ?>
						</div>
					</div>
				
					<div class="control-group">
						<?php echo $form->labelEx($model,'title',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'title',array('placeholder'=>'Tiêu đề trang','class'=>'span12')); ?>
							<?php echo $form->error($model,'title'); ?>
						</div>
					</div>

					<div class="control-group">
						<?php echo $form->labelEx($model,'description',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textArea($model,'description',array('placeholder'=>'Mô tả', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'description'); ?>
						</div>
					</div>

					<div class="control-group">
						<?php echo $form->labelEx($model,'phone',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'phone',array('placeholder'=>'Số điện thoại', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'phone'); ?>
						</div>
					</div>

					<div class="control-group">
						<?php echo $form->labelEx($model,'fax',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'fax',array('placeholder'=>'Fax', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'fax'); ?>
						</div>
					</div>

					<div class="control-group">
						<?php echo $form->labelEx($model,'address',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'address',array('placeholder'=>'Địa chỉ', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'address'); ?>
						</div>
					</div>

					<div class="control-group">
						<?php echo $form->labelEx($model,'email',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'email',array('placeholder'=>'Địa chỉ email', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'email'); ?>
						</div>
					</div>
					<div class="control-group">
						<?php echo $form->labelEx($model,'title_footer',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'title_footer',array('placeholder'=>'Tiêu đề cuối trang', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'title_footer'); ?>
						</div>
					</div>
					
					<div class="control-group">
						<?php echo $form->labelEx($model,'support_bunsinee',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'support_bunsinee',array('placeholder'=>'Hỗ trợ kinh doanh', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'support_bunsinee'); ?>
						</div>
					</div>
					
					<div class="control-group">
						<?php echo $form->labelEx($model,'hotline',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'hotline',array('placeholder'=>'Hotline', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'hotline'); ?>
						</div>
					</div>
					
					<div class="form-actions">
						<button id="submitForm" class="btn btn-primary" type="submit">
							<i class="icon-ok bigger-110"></i>
							<?php echo translate('Cập nhật');?>
						</button>

						&nbsp; &nbsp; &nbsp;
						<button type="button" onclick="location.href='<?php echo PIUrl::createUrl('/admin');?>'" class="btn " >
							<i class="icon-undo bigger-110"></i>
							<?php echo translate('hủy');?>
						</button>
					</div>
				<?php $this->endWidget(); ?>
			</div><!--/.span-->
		</div><!--/.row-fluid-->
	</div><!--/.page-content-->
<script>
	$("#system-form").submit(function(){
		$("#submitForm").attr("disabled", true);
	});
	
	$(document).ready(function(){
		$('.id-input-file-1').ace_file_input({
			no_file:'No File ...',
			btn_choose:'Chọn file',
			btn_change:'Thay đổi',
			droppable:false,
			onchange:null,
			before_change:before_change,
			thumbnail:false, //| true | large
			//whitelist:'gif|png|jpg|jpeg'
			blacklist:'exe|php'
			//onchange:''
		});
	})
	
	// validate khi upload file hinh anh
	before_change = function(files, dropped) {
		var allowed_files = [];
		for(var i = 0 ; i < files.length; i++) {
			var file = files[i];
			if(typeof file === "string") {
				//IE8 and browsers that don't support File Object
				if(! (/\.(jpe?g|png|gif|bmp)$/i).test(file) ) return false;
			}
			else {
				var type = $.trim(file.type);
				if( ( type.length > 0 && ! (/^image\/(jpe?g|png|gif|bmp)$/i).test(type) )
						|| ( type.length == 0 && ! (/\.(jpe?g|png|gif|bmp)$/i).test(file.name) )//for android's default browser which gives an empty string for file.type
					) continue;//not an image so don't keep this file
			}
			
			allowed_files.push(file);
		}
		if(allowed_files.length == 0) {message('Chỉ cho phép tải lên hình ảnh.','error'); return false};
		if(allowed_files[0].size > 2048000) {message('Kích thước ảnh quá lớn(phải nhỏ hơn 2048KB).','error'); return false};
		return allowed_files;
	}
</script>
</div><!--/.main-content-->